﻿using ChestPainCenterSystem.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ChestPainCenterSystem.ThreeCenterManage;

namespace ChestPainCenterSystem.Bll
{

    /// <summary>
    /// 病历相关
    /// </summary>
    public class MedicalRecordsManager : BaseManager
    {
        public static ThreeCenterManageSoapClient service = new ThreeCenterManageSoapClient();

        /// <summary>
        /// 获取科室下拉框
        /// </summary>
        /// <returns></returns>
        public static OperateResult GetDepartmentName()
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                ResultHelperOfListOfDropBox result = service.GetDepartmentName();
                if (result.S)
                {
                    resultInfo.Result = 1;
                    resultInfo.Body = result.D;
                }
                else
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }

            return resultInfo;
        }

        /// <summary>
        /// 获取医生/护士名字下拉框
        /// </summary>
        /// <param name="type">医生/护士</param>
        /// <returns></returns>
        public static OperateResult GetUserName(string type)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                ResultHelperOfListOfDropBox result = service.GetUserName(type);
                if (result.S)
                {
                    resultInfo.Result = 1;
                    resultInfo.Body = result.D;
                }
                else
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }

            return resultInfo;
        }


        /// <summary>
        /// 获取胸痛病历
        /// </summary>
        /// <param name="patientId"></param>
        /// <returns></returns>
        public static OperateResult GetCaseHistory(string patientId)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                ResultHelperOfString result = service.GetCaseHistory(patientId);
                if (result.S)
                {
                    resultInfo.Result = 1;
                    resultInfo.Body = result.D;
                }
                else
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }

            return resultInfo;
        }


        /// <summary>
        /// 修改胸痛病历
        /// </summary>
        /// <param name="patientId"></param>
        /// <returns></returns>
        public static OperateResult SetCaseHistory(string CaseJson)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                ResultHelperOfBoolean result = service.SetCaseHistory(CaseJson);
                if (result.S)
                {
                    resultInfo.Result = 1;
                    resultInfo.Body = result.M;
                }
                else
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }

            return resultInfo;
        }

    }
}